module SmppClient

  module Net

    # Abstract SMPP connection. All implementations should be thread safe.

    class Connection

      # Default incoming PDUs byte buffer size.
      DEFAULT_MAX_BUFFER_SIZE = 1000

      attr_reader :host, :port
      attr_accessor :max_buffer_size

      # SMSC host and port.
      def initialize(host, port)
        @host = host
        @port = port
        @max_buffer_size = DEFAULT_MAX_BUFFER_SIZE
      end

      # Open connection or raise ConnectionError.
      def open
        raise NotImplementedError
      end

      # Read incoming bytes and return one full pdu if possible.
      # if connection closed ConnectionClosedError raised.
      # If PDU invalid - PduError. ConnectionError otherwise.
      def read
        raise NotImplementedError
      end

      # Write outgoing PDU. if connection closed ConnectionClosedError raised.
      # If PDU invalid - PduError. ConnectionError otherwise.
      def write
        raise NotImplementedError
      end

      # Close connection. If connection already closed, method will do nothing.
      # After connection close #read and #write operations will raise ConnectionClosedError.
      # Connection may be reopened by calling #open method.
      def close
        raise NotImplementedError
      end

    end

  end

end